<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
		<meta name="renderer" content="webkit">
	    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
		<link rel="stylesheet" href="__PUBLIC__/frame/layui/css/layui.css">
	    <!--<link rel="stylesheet" href="http://cdn.datatables.net/1.10.13/css/jquery.dataTables.min.css">-->
	    <link rel="stylesheet" href="__PUBLIC__/frame/static/css/style.css">
	</head>
	<body>
		<a href="<?php echo U('lst')?>" class="layui-btn" style="margin-top: 10px; "><i class="layui-icon">&#xe603;</i>角色添加</a>
		<a class="layui-btn btn-add btn-default" id="btn-refresh"style="margin-top: 10px;"><i class="layui-icon">&#x1002;</i></a>

		<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
          <legend style="font-size: 14px;">角色添加</legend>
        </fieldset>
		<form class="layui-form layui-form-pane" action="__SELF__" method="post">
            <div class="layui-form-item">
                <label class="layui-form-label">上级角色</label>
                <div class="layui-input-inline">
                  <select name="pid" lay-filter="aihao">
                        <option value="0">顶级</option>
<?php foreach ($role as $k => $v):?>
                        <option value="{$v['id']}">{$v['role_name']}</option>
<?php endforeach;?>
                    </select>
                </div>
            </div>
			<div class="layui-form-item">
			    <label class="layui-form-label">角色名称</label>
			    <div class="layui-input-inline">
			      <input type="text" name="role_name" lay-verify="required" placeholder="请输入" autocomplete="off" class="layui-input">
			    </div>
			</div>
			
			<div class="layui-form-item" pane="">
			    <label class="layui-form-label">权限内容</label>
			    <div class="layui-input-block">
<?php foreach ($arr as $k => $v):?>
			  	<?php echo str_repeat('—',6*$v['level']);?>
			  	<input level="{$v.level}" type="checkbox" name="pri_id[]" title="{$v.pri_name}" value="{$v.id}" /><br/>
<?php endforeach;?>			     	      
			    </div>
			</div>
			
			<div class="layui-form-item">
			    <div class="layui-input-block">
			      <button type="submit" class="layui-btn" lay-submit="" lay-filter="demo1">立即提交</button>
			      <button type="reset" class="layui-btn layui-btn-primary">重置</button>
			    </div>
			</div>
		</form>	
		
	</body>
<script type="text/javascript" src="__PUBLIC__/frame/layui/layui.js"></script>
	<script>
layui.use(['form','jquery', 'layedit', 'laydate'], function(){
  var form = layui.form
  	,layer = layui.layer
  	,    $ =layui.jquery
  	,layedit = layui.layedit
  	,laydate = layui.laydate;

  	$('#btn-refresh').on('click', function () {
        location.reload();
    });
    // $(document).on('click',':checked',function(){
    // 	//alert(11);
    //     $cur_level = $(this).attr('level');//当前复选框级别
    //     if ($(this).is(':checked')) {
    //         //选中
    //         $prev = $(this).prevAll(':checkbox');//把所有父级选上
    //         $temp_level = $cur_level;
    //         //循环找出直接父级
    //         $prev.each(function(k,v){
    //             if($(v).attr('level')<$temp_level){
    //                $temp_level--;
    //                $(v).attr('checked',true);
    //            }

    //         });
    //         //选中父级，子级自动选中
    //         $next = $(this).nextAll(':checkbox');
    //         $next.each(function(k,v){
    //             if($(v).attr('level')>$cur_level){
    //                $(v).attr('checked',true);
    //            }else{
    //                return false;//遇到同级就停止
    //            }

    //         });
    //     }else{
    //         //取消，则取消所有子级
    //         $next = $(this).nextAll(':checkbox');
    //         $next.each(function(k,v){
    //             if($(v).attr('level')>$cur_level){
    //                $(v).removeAttr('checked');
    //            }else{
    //                return false;//遇到同级就停止
    //            }

    //         });
    //     }
    // });
  
});
</script>
</html>
